package com.gitee.wsl.func.ext

import com.gitee.wsl.func.BiCallAbleFun
import com.gitee.wsl.func.CallAbleFun
import com.gitee.wsl.func.RunWithResultFun
import com.gitee.wsl.func.SuspendBiCallAbleFun
import com.gitee.wsl.func.SuspendCallAbleFun
import com.gitee.wsl.func.SuspendRunWithResultFun
import kotlin.jvm.JvmName

fun <P1, R> CallAbleFun<P1,R>.partially1(p1: P1): RunWithResultFun<R> =
    { this(p1) }

fun <P1, P2, R> BiCallAbleFun<P1, P2, R>.partially1(p1: P1): CallAbleFun<P2,R> =
    { p2: P2 -> this(p1, p2) }

fun <P1, P2, R> BiCallAbleFun<P1, P2, R>.partially2(p2: P2): CallAbleFun<P1,R> =
    { p1: P1 -> this(p1, p2) }


@JvmName("partially1Effect")
fun <P1, R> SuspendCallAbleFun<P1,R>.partially1(p1: P1): SuspendRunWithResultFun<R> =
    { this(p1) }

@JvmName("partially1Effect")
fun <P1, P2, R> SuspendBiCallAbleFun<P1, P2, R>.partially1(p1: P1):SuspendCallAbleFun<P2,R> =
    { p2: P2 -> this(p1, p2) }

@JvmName("partially2Effect")
fun <P1, P2, R> SuspendBiCallAbleFun<P1, P2, R>.partially2(p2: P2): SuspendCallAbleFun<P1,R> =
    { p1: P1 -> this(p1, p2) }